<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    response.setHeader("cache-control","public");
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<!-- 创建试卷第二步 -->
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/paperMng.css">
    <style>
        .deletebox {
            margin-left: 6px;
            line-height: 175px !important;
        }
    </style>
    <script src="<%=path%>/static/js/respond.js"></script>
    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
    </script>
    <!-- <![endif]-->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-1.9.1.min.js'>" + "<" + "/script>");
    </script>
    <script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
    <script src="<%=path%>/static/js/jquery.selectlist.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
    <script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>

    <script>
        $(function () {
            $("[data-toggle='tooltip']").tooltip();
        });
    </script>
</head>
<body>
<!--head begin-->
<div id="header" class="header headbg">
    <div class="container">
        <jsp:include page="../head.jsp" flush="true"/>
    </div>
    <!--head end-->
    <!--body begin-->
    <div class="main-container">
        <div class="container body-box">
            <div class="title-top" style="background: #4c4ca6">
                <p>${paper.title}——<span class="rcolor">试卷配置</span></p>
                <a href="javascript:history.go(-1);" class="retun"><i class="glyphicon glyphicon-arrow-left"></i>返回</a>
            </div>
            <div class="paper-content">
                <div class="outcontent">
                    <!--步骤 begin-->
                    <div class="border_line">
                        <div id="fuelux-wizard" class="row-fluid" data-target="#step-container">
                            <ul class="wizard-steps">
                                <li class="nav_complete">
                                    <span class="step"><i class="glyphicon glyphicon-ok"></i></span>
                                    <span class="title">试卷基本信息</span>
                                </li>
                                <li class="nav_active">
                                    <span class="step">2</span>
                                    <span class="title">试卷配置信息</span>
                                </li>
                                <li>
                                    <span class="step">3</span>
                                    <span class="title">试卷发布</span>
                                </li>
                            </ul>
                        </div>
                    </div><!-- /.col -->
                    <!--步骤 end-->
                    <!--试卷配置信息 begin-->
                    <div class="deploy-main">
                        <%--<div class="deploy-top">
                            <a id="addexam" class="btn btn-default add-exam"><i
                                    class="glyphicon glyphicon-plus-sign"></i>请选择试题类型</a>
                            <!--<a class="btn btn-default loading">载入模板</a>-->
                        </div>--%>
                        <div id="deployadd" class="deploy-content" style="min-height: 314px;">
                            <!-- 新增页面空数据 -->
                            <c:if test="${flag == 'add' }">
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji" id="title_one">
                                                <option value="1">单项选择题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " disabled onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input name="chooseQuestion" type="text" style="text-align:center" value="去题库选择试题"
                                                   class="form-control" readonly="readonly" >
                                        </div>
                                    </div>
                                </div>
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji" id="title_muti">
                                                <option value="2">多项选择题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " disabled  onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input name="chooseQuestion" type="text" style="text-align:center" value="去题库选择试题"
                                                   class="form-control" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji" id="title_judge">
                                                <option value="0">判断题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " disabled onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value=" " onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input name="chooseQuestion" type="text" style="text-align:center" value="去题库选择试题"
                                                   class="form-control" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                            </c:if>
                            <!-- 编辑页面后台返回数据----------------------------单选-------------------------------------------------------------------------- -->
                            <c:if test="${flag == 'edit' }">
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji">
                                                <option value="1" selected>单项选择题</option>
                                                <option value="2">多项选择题</option>
                                                <option value="3">判断题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${singleEntity.count}" onBlur="textBlur(this)" disabled
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${singleEntity.score}" onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input name="chooseQuestion" type="text" value="去题库选择试题" style="text-align:center"
                                                   class="form-control" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="col-lg-1 col-md-1">

                                    </div>
                                </div>
                            <!-- 编辑页面后台返回数据-------------------------多选--------------------------------------------------------------- -->
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji">
                                                <option value="1">单项选择题</option>
                                                <option value="2" selected>多项选择题</option>
                                                <option value="3">判断题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${mutiEntity.count}" onBlur="textBlur(this)" disabled
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${mutiEntity.score}" onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input name="chooseQuestion" name="chooseQuestion" type="text" value="去题库选择试题" style="text-align:center"
                                                   class="form-control" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="col-lg-1 col-md-1">

                                    </div>
                                </div>
                            <!-- 编辑页面后台返回数据-----------------------判断------------------------------------ -->
                                <div class="deploybox row">
                                    <div class="col-lg-11 col-md-11 line-right">
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题目类型</span>
                                            <select name="jinji">
                                                <option value="1">单项选择题</option>
                                                <option value="2">多项选择题</option>
                                                <option value="3" selected>判断题</option>
                                            </select>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype ">
                                                    <span class="input-group-addon zjj">数量</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${judgeEntity.count}" onBlur="textBlur(this)" disabled
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">题</div>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-md-6 nopadleft">
                                                <div class="input-group input-group-lg deploytype">
                                                    <span class="input-group-addon zjj">分值</span>
                                                    <input type="text" class="form-control" maxlength="3"
                                                           value="${judgeEntity.score}" onBlur="textBlur(this)"
                                                           onFocus="textFocus(this)">
                                                    <div class="input-group-addon">分/题</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-lg deploytype">
                                            <span class="input-group-addon">题库选题</span>
                                            <input  name="chooseQuestion" type="text" value="去题库选择试题" style="text-align:center"
                                                   class="form-control" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="col-lg-1 col-md-1">

                                    </div>
                                </div>
                            </c:if>
                        </div>
                        <!--试卷配置信息 end-->
                        <div class="btnbox">
                            <a class="btn btn-success" onclick="precious()"><i
                                    class="glyphicon glyphicon-arrow-left" style="margin-left:0;"></i>上一步</a>
                            <a class="btn btn-info" onclick="next()" style="color: #FFFFFF">下一步<i
                                    class="glyphicon glyphicon-arrow-right" style="margin-right:0;"></i></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--body end-->


    <!--footer begin-->
    <!--footer end-->

    <script type="text/javascript">
        function precious(p, v) {
            history.go(-1);
        }
        $('input[name="chooseQuestion"]').click(function(){
            var regular = /^([0-9]*)$/;
            var score = $(this).parent().prev().children().eq(1).find('input').val();
            if (score == "") {
                BootstrapDialog.confirm({
                    title: '提示',
                    message: '分值不能为空',
                    size: BootstrapDialog.SIZE_SMALL,
                    type: BootstrapDialog.TYPE_DEFAULT,
                    closable: true,
                    btnCancelLabel: '取消',
                    btnOKLabel: '确定'
                });
                return
            }
            if (score <= 0) {
                BootstrapDialog.confirm({
                    title: '提示',
                    message: '分值不能小于0',
                    size: BootstrapDialog.SIZE_SMALL,
                    type: BootstrapDialog.TYPE_DEFAULT,
                    closable: true,
                    btnCancelLabel: '取消',
                    btnOKLabel: '确定'
                });
                return
            } else {
                if (!regular.test(score)) {
                    BootstrapDialog.confirm({
                        title: '提示',
                        message: '分值输入不符合',
                        size: BootstrapDialog.SIZE_SMALL,
                        type: BootstrapDialog.TYPE_DEFAULT,
                        closable: true,
                        btnCancelLabel: '取消',
                        btnOKLabel: '确定'
                    });
                    return
                }
            }
            var myForm = document.createElement("form");
            var questiontypeId = $(this).parent().prev().prev().find('select').val();
            myForm.method = "post";
            myForm.action = '<%=path%>/paper/toCheckQuestion';
            var questiontypeIdInput = document.createElement("input");
            questiontypeIdInput.setAttribute("name", "questiontypeId");  // 为input对象设置name
            questiontypeIdInput.setAttribute("value", questiontypeId);  // 为input对象设置value
            var ConId = document.createElement("input");
            ConId.setAttribute("name", "ConId");  // 为input对象设置name
            ConId.setAttribute("value", '${paper.extend}');  // 为input对象设置value
            var paperid = document.createElement("input");
            paperid.setAttribute("name", "paperid");  // 为input对象设置name
            paperid.setAttribute("value", '${paper.id}');  // 为input对象设置value

            var countInput = document.createElement("input");
            countInput.setAttribute("name", "count");  // 为input对象设置name
            countInput.setAttribute("value", '${paper.id}');  // 为input对象设置value

            var scoreInput = document.createElement("input");
            scoreInput.setAttribute("name", "score");  // 为input对象设置name
            scoreInput.setAttribute("value",score);  // 为input对象设置value
            myForm.appendChild(questiontypeIdInput);
            myForm.appendChild(ConId);
            myForm.appendChild(paperid);
            myForm.appendChild(countInput);
            myForm.appendChild(scoreInput);
            document.body.appendChild(myForm);
            myForm.submit();
            document.body.removeChild(myForm);  // 提交后移除创建的form
        });

        function next() {
            var len = $('#deployadd').children().length;
            var regular = /^([0-9]*)$/;
            var saveDataAry = [];
            var types = [];
            var scores = 0 ;
            var qsocre ='${paper.score}';
            for (var i = 0; i < len; i++) {
                var id = $("#deployadd").children().eq(i).children().find('div').eq(0).find('input').val();
                var type = $("#deployadd").children().eq(i).children().find('div').eq(0).find('select').val();
                var count = $("#deployadd").children().eq(i).children().find('div').eq(1).children().eq(0).children().find('input').val();
                var score = $("#deployadd").children().eq(i).children().find('div').eq(1).children().eq(1).children().find('input').val();
                var rate = $("#deployadd").children().eq(i).children().find('div').eq(1).children().eq(2).children().find('input').val();
                var easyrate = $("#deployadd").children().eq(i).children().find('div').eq(1).children().eq(3).children().find('input').val();
                types.push(type);
                var data = {
                    "id": id,
                    "paper_id": '${paper.id}',
                    "questiontype_id": type,
                    "count": count,
                    "score": score,
                    "rate": rate,
                    "easyrate": easyrate
                };
                scores += parseInt(score)*parseInt(count);
                saveDataAry.push(data);
            }

            //判断是否有重复
            var set = new Set();
            for (var i = 0; i < types.length; i++) {
                set.add(types[i])
            }

            $.ajax({
                dataType: 'json',
                contentType: "application/json",
                type: 'post',
                url: '<%=basePath%>paper/handsaveType',
                data: JSON.stringify(saveDataAry),
                success: function (data, status) {
                    var myForm = document.createElement("form");
                    myForm.method = "post";
                    myForm.action = "<%=path%>/paper/issue";
                    var myInput = document.createElement("input");
                    myInput.setAttribute("name", "paperid");  // 为input对象设置name
                    myInput.setAttribute("value", '${paper.id}');  // 为input对象设置value
                    myForm.appendChild(myInput);
                    document.body.appendChild(myForm);
                    myForm.submit();
                    document.body.removeChild(myForm);  // 提交后移除创建的form
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    BootstrapDialog.confirm({
                        title: '提示',
                        message: '系统错误',
                        size: BootstrapDialog.SIZE_SMALL,
                        type: BootstrapDialog.TYPE_DEFAULT,
                        closable: true,
                        btnCancelLabel: '取消',
                        btnOKLabel: '确定'
                    });
                }


            });

        }

        //paper-add-deploy.htm添加试题类型按钮
        $(document).ready(function () {

            // 试卷管理
            if (${role eq 'master'}) {
                $('#topMain').children().eq(0).addClass('active'); // 追加样式;
                $('#topMain').children().eq(0).children().attr('href', '#');
            } else if (${role eq 'trainee'}) {
                $('#topMain').children().eq(0).addClass('active'); // 追加样式;
                $('#topMain').children().eq(0).children().attr('href', '#');
            } else {
                $('#topMain').children().eq(4).addClass('active'); // 追加样式;
            }


            var nums = $(".knowsmain li").length;
            for (var i = 0; i < nums; i++) {
                $(".knowsmain").children().eq(i).find(".twobox").find("input").val(0);
            }
            var times = 0;
            var paperid = '${paper.extend}';
            $('#addexam').click(function () {
                times = times +1;
                var titleType = "";
                var titleVal = 0;
                if (times==1) {
                    titleType = "多项选择题";
                    titleVal = 2;
                } else if(times==2) {
                    titleType = "判断题";
                    titleVal = 3;
                }
                var tipcon =
                    '<div class="deploybox row">' +
                    '<div class="col-lg-11 col-md-11 line-right">' +
                    '<div class="input-group input-group-lg deploytype">' +
                    '<span class="input-group-addon">题目类型</span>' +
                    '<select name="jinji" >' +
                    '<option value='+titleVal+'>'+titleType+'</option>'+
                    '</select>' +
                    '</div>' +
                    '<div class="row">' +
                    '</div>' +
                    '<div class="input-group input-group-lg deploytype">'+
                    '<span class="input-group-addon">题库选题</span>'+
                    '<input type="text" value="去题库选择试题" style="text-align:center"'+
                    'class="form-control" readonly="readonly"'+
                    'onclick="chooseQuestion(\'<%=path%>/paper/toCheckQuestion\','+titleVal+','+paperid+')">'+
                    '</div>'+
                    '</div>'+
                    '<div class="col-lg-1 col-md-1">' +
                    '<div class="deletebox">' +
                    '<i class="glyphicon glyphicon-trash"></i>' +
                    '<a>删除</a>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                var len = $('#deployadd').children().length;
                if (len < 3) {
                    $('#deployadd').append(tipcon);
                }
                // 删除表单
                $('.deletebox a').click(function () {
                    len = $('#deployadd').children().length;
                    if (len > 1) {

                        $(this).parent().parent().parent().remove();
                        times = times - 1;
                    }
                });
            });
            // 删除表单
            $('.deletebox a').click(function () {
                var len = $('.deploybox').length;
                if (len > 1) {
                    var id = $(this).parent().parent().parent().find('div').find('input').val();

                    $(this).parent().parent().parent().remove();
                    times = times - 1;
                    $.ajax({
                        url: '<%=basePath%>paper/delpapertype',
                        data: {
                            id: id
                        },
                        success: function (data) {

                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            BootstrapDialog.confirm({
                                title: '提示',
                                message: '系统错误',
                                size: BootstrapDialog.SIZE_SMALL,
                                type: BootstrapDialog.TYPE_DEFAULT,
                                closable: true,
                                btnCancelLabel: '取消',
                                btnOKLabel: '确定'
                            });
                        }
                    });
                }
            });
            var val = "";
            var title = "";
            //当勾选时 checkbox
            //题库章节知识点设置 暂时没用着
            $(".knowsmain li .onebox .fxkbox").click(function () {
                var val = $(this).prev().val();
                var title = $(this).next().text();
                var obj = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().next();
                obj.val(title);
                console.info(obj);
            });

            //当点击弹窗确定按钮时，隐藏弹窗并把选择的数据放在知识点input中
            $(".zsd_qd").click(function () {
                $(this).parent().val();
                $('#close-cn').modal('hide');
            });
            $(".zsd_qx").click(function () {

                $('#close-cn').modal('hide');
            });
        });

        //文本框默认提示文字
        function textFocus(el) {
            if (el.defaultValue == el.value) {
                el.value = '';
                el.style.color = '#333';
            }
        }

        function textBlur(el) {
            score = $("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(1).children().eq(0).children().eq(1).val();
            scorenums = $("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(0).children().eq(0).children().eq(1).val();
            percent = $("#deployadd").children().eq(0).find(".line-right").children().eq(2).children().eq().children().eq(0).children().eq(1).val();
            var reg = /^\d+$/;// 这里是 正则表达式

            if (reg.test(scorenums) != true) {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(0).children().eq(0).children().eq(1).val("请输入所选试题类型总数").css("color","red");
            } else {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(0).children().eq(0).children().eq(1).css("color","#222");
            }
            if (reg.test(score) != true) {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(1).children().eq(0).children().eq(1).val("请输入该类型试题分值").css("color","red");
            } else {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(1).children().eq(0).children().eq(1).css("color","222");
            }
            if (reg.test(percent) != true) {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(2).children().eq(0).children().eq(1).val("请输入难题所占比例").css("color","red");
            } else {
                //$("#deployadd").children().eq(0).find(".line-right").children().eq(1).children().eq(2).children().eq(0).children().eq(1).css("color","222");
            }
        }
        //监听 浏览器的返回事件
        $(document).ready(function(e) {
            var counter = 0;
            if (window.history && window.history.pushState) {
                $(window).on('popstate', function () {
                    window.history.pushState('forward', null, '#');
                    window.history.forward(1);
                    //填写逻辑
                    var paperid = '${paper.id}';
                    var myForm = document.createElement("form");
                    myForm.method = "post";
                    myForm.action = "<%=path%>/paper/addOrEdit";
                    var myInput = document.createElement("input");
                    myInput.setAttribute("name", "id");  // 为input对象设置name
                    myInput.setAttribute("value", paperid);  // 为input对象设置value
                    myForm.appendChild(myInput);
                    document.body.appendChild(myForm);
                    myForm.submit();
                    document.body.removeChild(myForm);  // 提交后移除创建的form
                });
            }
            window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
            window.history.forward(1);
        });
    </script>
</div>
</body>
</html>
